package com.hay.item.mapper;

import com.hay.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface BrandMapper extends Mapper<Brand> {

    @Insert("insert into tb_category_brand(category_id, brand_id) values (#{id},#{bid})")
    void insertCategoryAndBrandId(@Param("id") long id, @Param("bid") long bid);

    @Delete("delete from tb_category_brand where brand_id = #{bid}")
    void deleteCategoryAndBrandByBid(long bid);

    @Select("select * from tb_brand b join tb_category_brand c on b.id = c.brand_id where c.category_id = #{cid}")
    List<Brand> queryBrandListByCid(long cid);
}
